package com.process.controller;


import com.auth.common.result.Result;
import com.auth.model.process.ProcessType;
import com.auth.utils.BooleanUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.process.service.OaProcessTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;

/**
 * <p>
 * 审批类型 前端控制器
 * </p>
 *
 * @author tang
 * @since 2023-07-23
 */
@Api(tags = "流程类型入口")
@RestController
@RequestMapping("/admin/process/processType")
public class OaProcessTypeController {
    private final OaProcessTypeService processTypeService;

    public OaProcessTypeController(OaProcessTypeService processTypeService) {
        this.processTypeService = processTypeService;
    }

    @ApiOperation("获取分页列表")
    @GetMapping("/{page}/{limit}")
    public Result index(@PathVariable Long page,
                        @PathVariable Long limit) {
        return Result.ok(processTypeService.page(new Page<>(page, limit)));
    }

    @ApiOperation(value = "获取")
    @GetMapping("get/{id}")
    public Result get(@PathVariable Long id) {
        ProcessType processType = processTypeService.getById(id);
        return Result.ok(processType);
    }

    @ApiOperation(value = "新增")
    @PostMapping("save")
    public Result save(@RequestBody ProcessType processType) {
        processTypeService.save(processType);
        return Result.ok();
    }

    @ApiOperation(value = "修改")
    @PutMapping("update")
    public Result updateById(@RequestBody ProcessType processType) {
        processTypeService.updateById(processType);
        return Result.ok();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable Long id) {
        processTypeService.removeById(id);
        return Result.ok();
    }

    @ApiOperation("查询所有审批分类")
    @GetMapping("/findAll")
    public Result findAll() {
        return Result.ok(processTypeService.list());
    }

}

